//define(function(require,exports) {
'use strict';
var mineApp = angular.module('mineApp', [
    'ngRoute',
    "ngSanitize",
    "ngFileUpload"
]);
mineApp.config(["$routeProvider","$httpProvider", function ($routeProvider,$httpProvider) {
    $httpProvider.defaults.headers.put['Content-Type'] = 'application/x-www-form-urlencoded';
    $httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
    $httpProvider.defaults.transformRequest = [function(data) {
        /**
         * The workhorse; converts an object to x-www-form-urlencoded serialization.
         * @param {Object} obj
         * @return {String}
         */
        var param = function(obj) {
            var query = '';
            var name, value, fullSubName, subName, subValue, innerObj, i;
            for (name in obj) {
                value = obj[name];
                if (value instanceof Array) {
                    for (i = 0; i < value.length; ++i) {
                        subValue = value[i];
                        fullSubName = name + '[' + i + ']';
                        innerObj = {};
                        innerObj[fullSubName] = subValue;
                        query += param(innerObj) + '&';
                    }
                } else if (value instanceof Object) {
                    for (subName in value) {
                        subValue = value[subName];
                        fullSubName = name + '[' + subName + ']';
                        innerObj = {};
                        innerObj[fullSubName] = subValue;
                        query += param(innerObj) + '&';
                    }
                } else if (value !== undefined && value !== null) {
                    query += encodeURIComponent(name) + '='
                        + encodeURIComponent(value) + '&';
                }
            }
            return query.length ? query.substr(0, query.length - 1) : query;
        };
        return angular.isObject(data) && String(data) !== '[object File]' ? param(data) : data;
    }];
    $routeProvider
        .when('/', {
            templateUrl: 'mine/main.html',
            controller: 'MainCtrl'
        })
        .when('/detail', {
            templateUrl: 'mine/detail.html',
            controller: 'DetailCtrl'
        })
        .when('/loginpw', {
            templateUrl: 'mine/loginpw.html',
            controller: 'LoginpwCtrl'
        })
        .when('/paypw', {
            templateUrl: 'mine/paypw.html',
            controller: 'PaypwCtrl'
        })
        .when('/booklist', {
            templateUrl: 'mine/booklist.html',
            controller: 'BooklistCtrl'
        })
        .when('/bookitem', {
            templateUrl: 'mine/bookitem.html',
            controller: 'BookitemCtrl'
        })
        .when('/dishlist', {
            templateUrl: 'mine/dishlist.html',
            controller: 'DishlistCtrl'
        })
        .when('/dishitem', {
            templateUrl: 'mine/dishitem.html',
            controller: 'DishitemCtrl'
        })
        .when('/integral', {
            templateUrl: 'mine/integral.html',
            controller: 'IntegralCtrl'
        })
        .when('/favo', {
            templateUrl: 'mine/favo.html',
            controller: 'FavoCtrl'
        })
        .when('/yield', {
            templateUrl: 'mine/yield.html',
            controller: 'YieldCtrl'
        })
        .when('/share', {
            templateUrl: 'mine/share.html',
            controller: 'ShareCtrl'
        })
        .when('/msg', {
            templateUrl: 'mine/msg.html',
            controller: 'MsgCtrl'
        })
        .when('/viewmsg/:id', {
            templateUrl: 'mine/viewmsg.html',
            controller: 'ViewmsgCtrl'
        })
        .when('/help', {
            templateUrl: 'mine/help.html',
            controller: 'HelpCtrl'
        })
        .otherwise({
            redirectTo: '/'
        });
}])
    //.run(["$window","$http","$location",function($window,$http,$location){
    //    //验证是否登录
    //    $http.get(hpfbase.url+"/user/isLogin.jhtm")
    //        .success(function(ret){
    //            if(!ret.succeed){
    //                $window.location.href="index.html#/login";
    //            }
    //        });
    //}])
    .directive("scrolly",function($window){
        //分页
        return{
            restrict: 'A',
            link: function(scope, element, attrs) {
                angular.element($window).bind("scroll", function (e) {
                    //($window.scrollY - $window.scrollMaxY > 0)
                    if($(window).scrollTop()+$(window).height() >=$(document).height()){
                        scope.$apply(attrs.scrolly);
                    }
                });
            }
        };
    });
//    window.mineApp =exports.mineApp = mineApp;
//});


var ui = {
    main:'<div class="g-hd">'+
    '    <div class="m-head g-fluid">'+
    '        <div class="g-xs4" ng-bind-html="back"></div>'+
    '        <div class="g-xs4"><div class="tt">用户中心</div></div>'+
    '        <div class="g-xs4 f-tar" ng-bind-html="next"></div>'+
    '    </div>'+
    '</div>'+
    '<div class="g-ct">'+
    '    <div class="m-mine">'+
    '        <a class="hd" href="#/detail">'+
    '            <div class="avatar"><img src="http://placehold.it/100x100/7ecdc5/fff" alt=""/></div>'+
    '            <div class="integral">2930积分</div>'+
    '            <div class="name">话别深秋'+
    '                <i class="icon-font v1" ng-show="user.level==1" title="v1">&#xe60c;</i>'+
    '                <i class="icon-font v2" ng-show="user.level==2" title="v2">&#xe60d;</i>'+
    '                <i class="icon-font v3" ng-show="user.level==3" title="v3">&#xe60e;</i>'+
    '                <i class="icon-font v4" ng-show="user.level==4" title="v4">&#xe610;</i>'+
    '                <i class="icon-font v5" ng-show="user.level==5" title="v5">&#xe612;</i>'+
    '                <i class="icon-font v6" ng-show="user.level==6" title="v6">&#xe611;</i>'+
    '                <i class="icon-font v7" ng-show="user.level==7" title="v7">&#xe613;</i>'+
    '            </div>'+
    '            <div class="location"><i class="icon-font" title="定位">&#xe619;</i>解放碑</div>'+
    '            <i class="icon-font arrow" title="arrow">&#xe600;</i></a>'+
    '        </a>'+
    '        <ul class="list">'+
    '            <li><a href="#/booklist">'+
    '                <i class="icon-font">&#xe60a;</i>'+
    '                <span>我的预定</span>'+
    '                <i class="icon-font arrow" title="arrow">&#xe600;</i></a>'+
    '            </li>'+
    '            <li><a href="#/dishlist">'+
    '                <i class="icon-font">&#xe614;</i>'+
    '                <span>我的点菜</span>'+
    '                <i class="icon-font arrow" title="arrow">&#xe600;</i></a>'+
    '            </li>'+
    '            <li><a href="#/integral">'+
    '                <i class="icon-font">&#xe616;</i>'+
    '                <span>我的积分</span>'+
    '                <i class="icon-font arrow" title="arrow">&#xe600;</i></a>'+
    '            </li>'+
    '            <li><a href="#/favo">'+
    '                <i class="icon-font">&#xe60b;</i>'+
    '                <span>我的关注</span>'+
    '                <i class="icon-font arrow" title="arrow">&#xe600;</i></a>'+
    '            </li>'+
    '            <li><a href="#/yield">'+
    '                <i class="icon-font">&#xe615;</i>'+
    '                <span>我的收益</span>'+
    '                <i class="icon-font arrow" title="arrow">&#xe600;</i></a>'+
    '            </li>'+
    '            <li><a href="#/share">'+
    '                <i class="icon-font">&#xe60f;</i>'+
    '                <span>我的推广</span>'+
    '                <i class="icon-font arrow" title="arrow">&#xe600;</i></a>'+
    '            </li>'+
    '        </ul>'+
    '    </div>'+
    '</div>',
}